{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e572d5e4-94a8-4059-bc1f-332e713b02e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b525ea5a-5f30-40ac-a98c-40394d788bba",
   "metadata": {},
   "source": [
    "### Set Difference Between Two Nupmy Arrays"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "bdb7936b-b56f-458e-9e72-70eeb7968190",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Function to take input array from user\n",
    "def np_array_frm_input(prompt):\n",
    "    try:\n",
    "        arr = list(map(int, input(prompt).split()))\n",
    "        np_array = np.array(arr, dtype=int)\n",
    "    except ValueError as e:\n",
    "        np_array = None\n",
    "        print(\"ERROR: Please enter only integers !!!\")\n",
    "        print(e)\n",
    "    return np_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1654ed7a-63f9-44bf-a30e-ea85ecd806fd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "\n",
      "Enter numbers for first sequence:  6 4 2\n",
      "\n",
      "Enter numbers for second sequence:  3 4\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The set difference between [6 4 2] and [3 4] is [2 6]\n"
     ]
    }
   ],
   "source": [
    "# Return the sorted, unique values in array1 that are not in array2\n",
    "np_arr1 = np_array_frm_input(\"\\nEnter numbers for first sequence: \")\n",
    "np_arr2 = np_array_frm_input(\"\\nEnter numbers for second sequence: \")\n",
    "print(f\"\\nThe set difference between {np_arr1} and {np_arr2} is {np.setdiff1d(np_arr1, np_arr2)}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
